package com.lx.video.biz.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lx.bilibili.entity.Videoplayhistroy;
import com.lx.video.biz.IVideoplayhistroyService;
import com.lx.video.dao.VideoplayhistroyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lx
 * @since 2025-04-06
 */
@Service
public class VideoplayhistroyServiceImpl extends ServiceImpl<VideoplayhistroyMapper, Videoplayhistroy> implements IVideoplayhistroyService {

    @Autowired
    VideoplayhistroyMapper videoplayhistroyMapper;

    public int saveVideoProgress(Videoplayhistroy videoplayhistroy){
        LambdaQueryWrapper<Videoplayhistroy> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Videoplayhistroy::getUid, videoplayhistroy.getUid());
        lqw.eq(Videoplayhistroy::getVid, videoplayhistroy.getVid());
        Videoplayhistroy IsExist = videoplayhistroyMapper.selectOne(lqw);
        if(IsExist!=null){
            IsExist.setEndtime(videoplayhistroy.getEndtime());
            return videoplayhistroyMapper.updateById(IsExist);
        }else{
            return videoplayhistroyMapper.insert(videoplayhistroy);
        }
    }
}
